<?php
namespace app\admin\controller;


use app\common\controller\AdminBase;
use app\common\model\AdTemplate;
use app\common\model\PayConfig;
use think\Request;

/**
 * 拍币规则
 * Class AdRule
 * @package app\admin\controller
 */
class CoinRule extends AdminBase
{


    /**
     * @return \think\response\View
     * 规则视图
     */
    public function edit()
    {
        $coin_rule = PayConfig::get(1);

        return view('add',compact('coin_rule'));
    }

    /**
     * @param Request $request
     * 保存规则
     */
    public function save(Request $request)
    {
        $id = $request->param('id');
        $data['coin'] = $request->param('coin');
        $data['coin_to_money'] = $request->param('coin_to_money');

        if (PayConfig::where(['id'=>$id])->update($data)) {
            $action = "拍币规则ID" . $id;
            $this->getLog("3", $action);
            $this->success('修改成功');
        } else {
            $this->error('修改失败');
        }

    }


}